const {User} = require("../model");
const {body} = require("express-validator");

//用户注册

exports.register = async (req, res, next) => {
    try {
        const user = new User(req.body.user);
        await user.save();
        req.session.user = user;
        res.status(201).json({
            user
        });
    } catch (err) {
        next(err);
    }
}

//用户登录
exports.login = async (req, res, next)=> {
    try {
        const user = new User(req.body.user);
        req.session.user = user;
        console.log(req.session.user)
        res.status(200).json({
            user
        })
    } catch (err) {
        next(err);
    }
}


//获取用户信息
exports.getUserMess = async (req,res,next)=>{
    try{
        res.send(`获取用户信息`)
    }catch (err){
        next(err);
    }
}

//更新用户信息
exports.updateMess = async (req,res,next)=>{
    try{
        res.send(``)
    }catch (err){
        next(err);
    }
}